*This file can be used to clean the macro data on income levels and national unemployment used in the paper "Macroeconomic Conditions When Young Shape Job Preferences for Life"

*1. Regional income levels are available on a yearly basis from the Bureau of Economic Analysis, from 1929. (Raw data income29.dta is cleaned to create the file RegionalIncome.dta)

*2. National unemployment rates are available on a yearly basis the Bureau of Labour statistics, from 1929 (Raw data unemployment29.dta is cleaned to create the file NationalUnemployment.dta).



///// 1. Regional Income: creating RegionalIncome.dta ////////////

cd ""


clear all
use "income29.dta"

rename geoname state
rename description type_income


keep if type_income=="Per capita personal income (dollars) 2/"
reshape long y , i(state) j(year)

rename y income_capita
drop type_income



drop if state=="Far West"
drop if state=="Great Lakes"
drop if state=="Mideast"
drop if state=="New England"
drop if state=="Plains"
drop if state=="Rocky Mountain"
drop if state=="Southeast"
drop if state=="Southwest"

tab state

gen region=.
replace region=1 if state=="Maine" | state=="Vermont" | state=="New Hampshire" | state=="Massachusetts" | state=="Rhode Island" | state=="Connecticut"  
replace region=2 if state=="New York" | state=="New Jersey" | state=="Pennsylvania" 
replace region=3 if state=="Ohio" | state=="Indiana" | state=="Wisconsin" | state=="Michigan" | state=="Illinois" 
replace region=4 if state=="Minnesota" | state=="Iowa" | state=="North Dakota" | state=="South Dakota" | state=="Nebraska" | state=="Kansas"  | state=="Missouri"  
replace region=5 if state=="Florida" | state=="Georgia" | state=="South Carolina" | state=="North Carolina" | state=="West Virginia" | state=="Maryland"  | state=="Delaware"  | state=="Virginia" | state=="District of Columbia"
replace region=6 if state=="Kentucky" | state=="Tennessee" | state=="Alabama" | state=="Mississippi" 
replace region=7 if state=="Oklahoma" | state=="Arkansas" | state=="Texas" | state=="Louisiana"
replace region=8 if state=="Montana" | state=="Wyoming" | state=="Idaho" | state=="Nevada" | state=="Utah" | state=="Colorado"  | state=="Arizona"  | state=="New Mexico" 
replace region=9 if state=="Washington" | state=="Oregon" | state=="California" | state=="Alaska*" | state=="Hawaii*"

save "incomecapita29.dta", replace


clear all
use "income29.dta"

rename geoname state
rename description type_income


keep if type_income=="Population (persons) 1/"
reshape long y , i(state) j(year)

rename y population
drop type_income

drop if state=="Far West"
drop if state=="Great Lakes"
drop if state=="Mideast"
drop if state=="New England"
drop if state=="Plains"
drop if state=="Rocky Mountain"
drop if state=="Southeast"
drop if state=="Southwest"

tab state

gen region=.
replace region=1 if state=="Maine" | state=="Vermont" | state=="New Hampshire" | state=="Massachusetts" | state=="Rhode Island" | state=="Connecticut"  
replace region=2 if state=="New York" | state=="New Jersey" | state=="Pennsylvania" 
replace region=3 if state=="Ohio" | state=="Indiana" | state=="Wisconsin" | state=="Michigan" | state=="Illinois" 
replace region=4 if state=="Minnesota" | state=="Iowa" | state=="North Dakota" | state=="South Dakota" | state=="Nebraska" | state=="Kansas"  | state=="Missouri"  
replace region=5 if state=="Florida" | state=="Georgia" | state=="South Carolina" | state=="North Carolina" | state=="West Virginia" | state=="Maryland"  | state=="Delaware"  | state=="Virginia" | state=="District of Columbia"
replace region=6 if state=="Kentucky" | state=="Tennessee" | state=="Alabama" | state=="Mississippi" 
replace region=7 if state=="Oklahoma" | state=="Arkansas" | state=="Texas" | state=="Louisiana"
replace region=8 if state=="Montana" | state=="Wyoming" | state=="Idaho" | state=="Nevada" | state=="Utah" | state=="Colorado"  | state=="Arizona"  | state=="New Mexico" 
replace region=9 if state=="Washington" | state=="Oregon" | state=="California" | state=="Alaska*" | state=="Hawaii*"

replace population=population/1000000

save "incomepop29.dta", replace

clear all
use "income29.dta"

rename geoname state
rename description type_income


keep if type_income=="Personal income (millions of dollars)"
reshape long y , i(state) j(year)

rename y income_total
drop type_income

drop if state=="Far West"
drop if state=="Great Lakes"
drop if state=="Mideast"
drop if state=="New England"
drop if state=="Plains"
drop if state=="Rocky Mountain"
drop if state=="Southeast"
drop if state=="Southwest"

tab state

gen region=.
replace region=1 if state=="Maine" | state=="Vermont" | state=="New Hampshire" | state=="Massachusetts" | state=="Rhode Island" | state=="Connecticut"  
replace region=2 if state=="New York" | state=="New Jersey" | state=="Pennsylvania" 
replace region=3 if state=="Ohio" | state=="Indiana" | state=="Wisconsin" | state=="Michigan" | state=="Illinois" 
replace region=4 if state=="Minnesota" | state=="Iowa" | state=="North Dakota" | state=="South Dakota" | state=="Nebraska" | state=="Kansas"  | state=="Missouri"  
replace region=5 if state=="Florida" | state=="Georgia" | state=="South Carolina" | state=="North Carolina" | state=="West Virginia" | state=="Maryland"  | state=="Delaware"  | state=="Virginia" | state=="District of Columbia"
replace region=6 if state=="Kentucky" | state=="Tennessee" | state=="Alabama" | state=="Mississippi" 
replace region=7 if state=="Oklahoma" | state=="Arkansas" | state=="Texas" | state=="Louisiana"
replace region=8 if state=="Montana" | state=="Wyoming" | state=="Idaho" | state=="Nevada" | state=="Utah" | state=="Colorado"  | state=="Arizona"  | state=="New Mexico" 
replace region=9 if state=="Washington" | state=="Oregon" | state=="California" | state=="Alaska*" | state=="Hawaii*"

save "incometotal29.dta", replace

merge 1:1 state year using "incomecapita29.dta"
drop _merge
merge 1:1 state year using "incomepop29.dta"
drop _merge

save "RegionalIncome.dta", replace


///// 2. National Unemployment: creating NationalUnemployment.dta ////////////


clear all
use "unemployment29.dta"

reshape long yr , i(country) j(year)
drop countryname 
rename yr unemploy_rate

tsset year
gen l1_ur=l.unemploy_rate 
gen l2_ur=ll.unemploy_rate

save "NationalUnemployment.dta", replace

